﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Microsoft.Practices.Unity;
using Vit.Web.Services;

namespace Vit.Web.DataAnnotations
{
    [AttributeUsage(AttributeTargets.All)]
    public class DescriptionAttribute : System.ComponentModel.DescriptionAttribute
    {
        public DescriptionAttribute(string discription)
        {
            IUnityContainer unity = ((VitApplication)HttpContext.Current.ApplicationInstance).UnityContainer;
            ILocalizationService localize = unity.Resolve<ILocalizationService>();
            if (localize != null)
                this.DescriptionValue = localize.Resource(Area, discription);
            else
                this.DescriptionValue = discription;
        }

        public string Area { get; set; }
    }
}
